﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BLL.Progect
{
    public class T_PUB_PROJECTFILE
    {
        private readonly DALL.Progect.T_PUB_PROJECTFILE dal = new DALL.Progect.T_PUB_PROJECTFILE();
        public T_PUB_PROJECTFILE()
        { }
        /// <summary>
        /// 获取文件下的项目
        /// </summary>
        /// <param name="FileId"></param>
        /// <returns></returns>
        public DataSet GetProjectList(string FileId)
        {
            string strWhere = string.Format(" and f.FILE_ID='{0}'", FileId);
            return dal.GetProjectList(strWhere);
        }

        #region 订单里的项目图片
        public DataTable GetProjectImageUrl(string strIDS)
        {
            string strarrid = "";
            if (strIDS.IndexOf(",") >= 0)
            {
                string[] strArry = strIDS.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string item in strArry)
                {
                    strarrid = strarrid + string.Format("'{0}'", item) + ",";
                }
                if (strarrid.Length > 0)
                {
                    strarrid = strarrid.Substring(0, strarrid.Length - 1);
                }
            }
            else
            {
                strarrid = "'" + strIDS + "'";
            }

            string strWhere = string.Format(" and pf.PROJECT_ID in ({0}) ", strarrid);
            return dal.GetProjectImageUrl(strWhere);
        }
        #endregion

        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            return dal.Exists(ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Progect.T_PUB_PROJECTFILE model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Progect.T_PUB_PROJECTFILE model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {

            return dal.Delete(ID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Progect.T_PUB_PROJECTFILE GetModel(int ID)
        {

            return dal.GetModel(ID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Progect.T_PUB_PROJECTFILE> GetModelList(string strWhere)
        {
            return dal.GetListArray(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  Method
    }
}
